package com.qf.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.bean.Employee;
import com.qf.dao.EmployeeMapper;
import com.qf.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
 * 2020/2/2
 * 键盘敲烂，月薪过万
 * 登高必自卑，行远必自迩。
 * 不忘初心：像初学者一样拥有一颗谦虚、开放的心态。
 * 李学峰
 */
@Service
public class EmployeeServiceImpl implements EmployeeService {

   @Autowired
   private EmployeeMapper employeeMapper;


    @Override
    public PageInfo<Employee> getall(
            int pageIndex,int pageSize,  String username,String rolename,String deptname) {
        //指定分页的参数
        PageHelper.startPage(pageIndex, pageSize);
        //取读dao层方法
        HashMap map = new HashMap();
        map.put("uname",username);
        map.put("rname",rolename);
        map.put("dname",deptname);
        List<Employee> findall = employeeMapper.findall(map);
        //封装pageinfo
        PageInfo info = new PageInfo(findall);
        return info;
    }

    //登录
    @Override
    public Employee login(String username, String password) {
        Employee login = employeeMapper.login(username);
        if (login!=null){
            //正确
            if (password.equals(login.getLoginpassword())){
                return login;
            }
            return null;
        }
        return null;
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return 0;
    }

    @Override
    public int insert(Employee rocord) {
        return 0;
    }

    @Override
    public int insertSelective(Employee rocord) {
        return 0;
    }

    @Override
    public Employee selectByPrimaryKey(Integer id) {
        return null;
    }

    @Override
    public int updateByPrimaryKeySelective(Employee rocord) {
        return 0;
    }

    @Override
    public int updateByPrimaryKey(Employee employee) {
        return 0;
    }
}
